﻿<ViewDataFormTemplateSpec 
	xmlns="bb_appfx_viewdataformtemplate" 
	xmlns:common="bb_appfx_commontypes" 
	ID="d0cdb435-8ef0-4db6-a962-4a1ee52ce218" 
	Name="Email Address GUID View Form"
	Description="Get the GUID of an email address record from the custom ID"
	Author="Blackbaud Professional Services"
	DataFormInstanceID="75c85f9c-af63-4dfc-91d2-53063519fbcb" 
	RecordType="EmailAddress"
	common:SecurityUIFolder="Service Bus Adapter"
	>

    <!-- define the SP that returns the data used by the form -->
    <SPDataForm SPName="USR_USP_DATAFORMTEMPLATE_VIEW_EMAILADDRESS_GET_GUID">
      <common:CreateProcedureSQL>
        <![CDATA[
create procedure dbo.USR_USP_DATAFORMTEMPLATE_VIEW_EMAILADDRESS_GET_GUID
(
	@ID nvarchar(255),
	@DATALOADED bit = 0 output,
	@EMAILADDRESSID uniqueidentifier = null output
)
as
	set nocount on;
	
	-- be sure to set this, in case the select returns no rows
	set @DATALOADED = 0;
	
	-- populate the output parameters, which correspond to fields on the form.  Note that
	-- we set @DATALOADED = 1 to indicate that the load was successful.  Otherwise, the system
	-- will display a "no data loaded" message.
	select 
    @DATALOADED = 1,
		@EMAILADDRESSID = a.ID
	from 
    dbo.EMAILADDRESS a
    inner join dbo.USR_EMAILADDRESS uea on a.ID = uea.ID
	where 
    uea.LOOKUPID = @ID 
	
	return 0;
			]]>
      </common:CreateProcedureSQL>
    </SPDataForm>

    <!-- describe fields on the form, which correspond to parameters on the SP.  Note that system paramters 
	like the context @ID, @DATALOADED, and @CURRENTAPPUSERID need not be listed. -->
    <common:FormMetaData FixedDialog="true">
      <common:FormFields>
        <common:FormField FieldID="EMAILADDRESSID" Caption="Email Address ID" DataType="Guid" />
      </common:FormFields>
    </common:FormMetaData>

  </ViewDataFormTemplateSpec>